;:sys36864
; mps 803 grafikeditor 14.1.1986
; <c> nicki heusler
	;.opt oo
;
spalte	= 211
zeile	= 214
setcr	= $e56c
joy	= 56320
shift	= 653
farbe	= 55296
screen	= 648
tmp	= 2
zeil	= 14
max	= 40
crhome	= $e566
clrx	= $e9ff
bild	= $d1
joytmp	= 4
crsr1	= 204
crsr2	= 205
crsr3	= 207
getkey	= $ffe4
cint	= 65409
frame	= 53280
paper	= 53281
ink	= 646
strout	= $ab1e
write	= $ffd2
buffer	= 51200
setx	= $e9f0
lf	= $b8
sa	= $b9
ga	= $ba
open	= $ffc0
close	= $ffc3
chkout	= $ffc9
clrchn	= $ffcc
return	= $aad7
axout	= $bdcd
;
	*= 49152
	jmp start
jedit	jmp edit
grbit	.byt 1,2,4,8,$10,$20,$40
tx1	.byte "\x99\x92\x13\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3"
	.byte "\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\x11\x11graphikeditor mps 803"
	.byte " by nss software 86\x11 \x12 f1 \x92 edit" 
	 .byt 13
	.byte " \x12 f3 \x92 quit" 
	 .byt 13
	.byte " \x12 f5 \x92 print" 
	 .byt 13
	.byte " \x12 f7 \x92 data" 
	 .byt 0
tx2	.byte "\x99\x92\x13\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3"
	.byte "\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\x11\x11               -- edit --" 
	 .byt 13
	.byte " \x12 c= \x92         exit" 
	 .byt 13
	.byte " \x12 shift \x92      clear dot" 
	 .byt 13
	.byte " \x12 joystick 2 \x92 move" 
	 .byt 13
	.byte " \x12 fire \x92       (re)set dot" 
	 .byt 0
tx3	.byte "switch on printer," 
	 .byt 13
	.byte "insert paper," 
	 .byt 13
	.byte "press a key" 
	 .byt 13
	.byte "\x12 _\xc0 \x92 to abort" 
	 .byt 0
tx4	.byte "\x99\x92\x13\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3"
	.byte "\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\x11\x11              -- print data --" 
	 .byt 13,0
tx5	.byte "\x99\x92\x13\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\x11\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3"
	.byte "\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\xa3\x11\x11            -- print graphic --" 
	 .byt 13,0
tx6	.byte "\x0egrafik - daten:\x0f" 
	 .byt 13,13,0
;
colx	txa 
	 ldx #zeil
	ldy #>farbe 
	 sty tmp+1
	ldy #0 
	 sty tmp
setc	sta (tmp),y 
	 iny
	cpy #max 
	 bcc setc 
	 ldy #0
	pha 
	 lda #max 
	 clc 
	 adc tmp
	sta tmp 
	 lda tmp+1 
	 adc #0
	sta tmp+1 
	 pla 
	 dex 
	 bne setc
	rts
home	lda #0 
	 sta tmp
	lda screen 
	 sta tmp+1
	jmp crhome
down	inc zeile
	lda zeile 
	 cmp #zeil
	bcc hochg 
	 dec zeile
hochg	jmp setcr
up	dec zeile 
	 lda zeile
	bpl untg 
	 inc zeile
untg	jmp setcr
right	inc spalte
	lda spalte 
	 cmp #max
	bcc rechg 
	 dec spalte
rechg	jmp setcr
left	dec spalte 
	 lda spalte
	bpl linkg 
	 inc spalte
linkg	jmp setcr
fire	ldy spalte
	lda shift 
	 and #1
	php 
	 ldx #32 
	 plp 
	 bne dot
	ldx #160
dot	txa 
	 sta (bild),y 
	 rts
curon	lda #0 
	 sta crsr1 
	 rts
curoff	lda #2 
	 sta crsr2
cwait	lda crsr3 
	 bne cwait
	lda #1 
	 sta crsr1 
	 rts
clr	ldx #zeil-1 
	 lda farbe 
	 pha
clrloop	jsr clrx 
	 dex
	bpl clrloop 
	 pla 
	 tax
	jsr colx 
	 jmp home
edittxt	jsr clrdwn
	lda #<tx2 
	 ldy #>tx2
	jmp strout
clrdwn	ldx #zeil
cloop	jsr clrx 
	 inx
	cpx #25 
	 bcc cloop 
	 rts
settings	lda #<tx3 
	 ldy #>tx3
	jsr strout
get	jsr getkey 
	 beq get
	cmp #"_" 
	 beq break
	sec 
	 rts
break	clc 
	 rts
tit1	jsr clrdwn
	lda #<tx4 
	 ldy #>tx4 
	 jmp strout
tit2	jsr clrdwn
	lda #<tx5 
	 ldy #>tx5 
	 jmp strout
getnrob	ldx #0 
	 stx tmp
get1	jsr setx
	lda (bild),y 
	 cmp #32
	beq noad1 
	 lda grbit,x 
	 clc
	adc tmp 
	 sta tmp
noad1	inx 
	 cpx #7 
	 bcc get1
	rts
getnrun	ldx #0 
	 stx tmp
	ldx #7
get2	jsr setx
	lda (bild),y 
	 cmp #32
	beq noad2 
	 lda grbit-7,x 
	 clc
	adc tmp 
	 sta tmp
noad2	inx 
	 cpx #14 
	 bcc get2
	rts
edit	jsr edittxt 
	 jsr home
loop	jsr curon
waitj	lda joy 
	 and #31 
	 cmp #31
	bne press 
	 lda shift 
	 and #2
	bne cbm 
	 jmp keys
cbm	jmp curoff
press	jsr curoff 
	 lda joy
	sta joytmp 
	 and #1
	bne no1 
	 jsr up
no1	lda joytmp 
	 and #2
	bne no2 
	 jsr down
no2	lda joytmp 
	 and #4
	bne no3 
	 jsr left
no3	lda joytmp 
	 and #8
	bne no4 
	 jsr right
no4	lda joytmp 
	 and #16
	bne no5 
	 jsr fire
no5	ldy #255 
	 ldx #80
waitloop	dey 
	 bne waitloop
	dex 
	 bne waitloop
	jmp loop
keys	jsr getkey 
	 bne key
	jmp waitj
key	pha 
	 jsr curoff 
	 pla 
	 cmp #"\x93"
	bne nk1 
	 jsr clr 
	 jmp loop
nk1	cmp #"\x13" 
	 bne nk2
	jsr home 
	 jmp loop
nk2	jmp loop
start	jsr cint
	lda #0 
	 sta frame 
	 sta paper
back	jsr clrdwn
	lda #<tx1 
	 ldy #>tx1
	jsr strout 
	 ldx #14
	jsr colx
go	jsr getkey
	cmp #"\x85" 
	 bne nof1
	jsr edit 
	 jmp back
nof1	cmp #"\x86" 
	 bne nof3
	rts
nof3	cmp #"\x87" 
	 bne nof5
	jmp grafik
nof5	cmp #"\x88" 
	 bne nof7
	jmp datas
nof7	jmp go
datas	jsr tit1 
	 jsr settings
	bcc back
	jsr calc
	lda #4 
	 sta ga 
	 sta lf
	lda #0 
	 sta sa 
	 jsr open
	ldx #4 
	 jsr chkout
	lda #<tx6 
	 ldy #>tx6 
	 jsr strout
	ldy #0
num	lda buffer,y 
	 beq fin
	sty tmp 
	 tax 
	 lda #0
	jsr axout 
	 jsr return 
	 ldy tmp
	iny 
	 bne num
fin	jmp printend
grafik	jsr tit2 
	 jsr settings
	bcc ret
	jsr calc
	lda #4 
	 sta ga 
	 sta lf
	lda #0 
	 sta sa 
	 jsr open
	ldx #4 
	 jsr chkout
	lda #8 
	 jsr write
	lda #<buffer 
	 ldy #>buffer
	jsr strout
	lda #15 
	 jsr write
printend	jsr return
	jsr clrchn 
	 lda #4 
	 jsr close
ret	jmp back
calc	ldy #0
calc1	jsr getnrob 
	 lda tmp
	clc 
	 adc #128 
	 sta buffer,y
	iny 
	 cpy #40 
	 bcc calc1
	lda #13 
	 sta buffer,y
	ldy #0
calc2	jsr getnrun 
	 lda tmp
	clc 
	 adc #128 
	 sta buffer+41,y
	iny 
	 cpy #40 
	 bcc calc2
	lda #13 
	 sta buffer+41,y
	lda #0 
	 sta buffer+42,y 
	 rts
